package cn.wolfcode.luowowo.mgrsite.controller;

import cn.wolfcode.luowowo.article.service.IDestinationService;
import cn.wolfcode.luowowo.common.query.DestinationQuery;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/destination")
public class DestinationController {

    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(@ModelAttribute("qo") DestinationQuery qo, Model model){
        PageInfo pageInfo = destinationService.query(qo);
        model.addAttribute("pageInfo",pageInfo);
        model.addAttribute("toasts",destinationService.toastsList(qo.getParentId()));
        return "destination/list";
    }

    @RequestMapping("/changeHotState")
    @ResponseBody
    //修改热门状态
    public AjaxResult changeHotState(Long id, int hot){
        return destinationService.changeHotState(id,hot);
    }

    @RequestMapping("/setInfo")
    @ResponseBody
    //修改简介
    public AjaxResult setInfo(Long id, String info){
        return destinationService.setInfo(id,info);
    }

}
